package com.controller;

import com.util.Controller;
import com.util.RequestMapping;
import com.util.Util;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage;

@Controller
public class commonController {
    /**
     * 共用验证码
     * @param request
     * @param response
     * @return
     */
    @RequestMapping("/authCode")
    public BufferedImage authCode(HttpServletRequest request, HttpServletResponse response){
        //创建一个6位的验证码
        String checkCode = Util.createCheckCode(6);
        //保存验证码到session
        request.getSession().setAttribute("checkCode",checkCode);
        //创建验证码的图片
        BufferedImage bufferedImage = Util.getImg(checkCode);

        return bufferedImage;
    }
}
